package com.yunxi.controller.activiti;


import com.yunxi.sys.pojo.PosVO;
import com.yunxi.sys.pojo.RoleUserVO;
import com.yunxi.sys.pojo.RoleVO;
import com.yunxi.sys.pojo.UserVO;
import com.yunxi.sys.service.PosDubboService;
import com.yunxi.sys.service.RoleDubboService;
import com.yunxi.sys.service.RoleUserDubboService;
import com.yunxi.sys.service.UserDubboService;
import io.swagger.annotations.Api;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2019/7/26.
 */
@RestController
@Api(tags = "activiti:parameter", description = "工作流画图扩展接口")
public class ActivitiParameterController {
    protected static final Logger LOGGER = LoggerFactory.getLogger(ModelEditorJsonRestResource.class);
    @Autowired
    PosDubboService posDubboService;
    @Autowired
    RoleDubboService roleDubboService;
    @Autowired
    RoleUserDubboService roleUserDubboService;
    @GetMapping(value={"/service/sysRole/list"}, produces={"application/json"})
    public List<RoleVO> getRoleList() {
        LOGGER.debug("进入获取角色");
        List<RoleVO> roleVOList = new ArrayList<RoleVO>();
        RoleVO roleVO = new RoleVO();
        try{
           //查询所有角色
            roleVOList = roleDubboService.listByVo(roleVO);
        }catch (Exception e){
            e.printStackTrace();
        }
        return roleVOList;
    }


    @PostMapping(value={"/service/sysUser/list"}, produces={"application/json"})
    public List<UserVO> getUserList(String roleId) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException {
        LOGGER.debug("根据选取的角色取用户");
        return roleUserDubboService.userListByRoleId(roleId);
    }
}
